<?php
namespace route;
use app\common\middleware\AdminAuthMiddleware;
use app\common\middleware\AdminTokenMiddleware;
use app\common\middleware\AllowOriginMiddleware;
use think\facade\Route;

Route::group('admin',function () {
    Route::miss(function () {
        $DB = DIRECTORY_SEPARATOR;
        return view(app()->getRootPath() . 'public/admin' . $DB . 'index.html');
    });
});


Route::group('sys',function (){
    Route::group(function () {

        Route::group('admin',function (){
            Route::get('lst', '/getList')->name('userLst');
            Route::post('create', '/create');
            Route::delete('delete/:id', '/delete');
            Route::post('update/:id', '/update');
            Route::post('password/:id', '/password');
        })->prefix('admin.system.admin.Admin');

        Route::group('user_extract',function (){
            Route::group('',function (){
                Route::get('lst','/lst');
                Route::post('audit/:id','/audit');
            })->prefix('admin.info.Extract');
        });


        Route::group('ad_task',function (){
            Route::group('package',function (){
                Route::get('lst', '/packageLst');
                Route::post('create', '/packageCreate');
                Route::delete('delete/:id', '/packageDelete');
                Route::post('update/:id', '/packageUpdate');
            })->prefix('admin.info.AdTask');


            Route::group('',function (){
                Route::get('lst', '/lst');
                Route::post('audit', '/audit');
            })->prefix('admin.info.AdTask');
        });


        Route::group('order',function (){
            Route::get('lst', '/lst')->name('userLst');
            Route::post('create', '/create');
            Route::delete('delete/:id', '/delete');
            Route::post('update/:id', '/update');
            Route::post('status/:id', '/status');
            Route::get('detail/:id', '/detail');
            Route::get('downLoad/:id', '/downLoad');
        })->prefix('admin.info.Order');


        Route::get('getExt','admin.Common/getMaterial');
        Route::post('setExt','admin.Common/setMaterial');

        Route::get('getPrintStyle','admin.Common/getPrintStyle');
        Route::post('setPrintStyle','admin.Common/setPrintStyle');


        Route::post('systemSetting','admin.Common/systemSetting');
        Route::get('systemSetting','admin.Common/getSystemSetting');


        Route::group('size',function (){
            Route::get('lst', '/sizeLst');
            Route::post('create', '/sizeCreate');
            Route::delete('delete/:id', '/sizeDelete');
            Route::post('update/:id', '/sizeUpdate');
        })->prefix('admin.info.Order');


        Route::group('article',function (){
            Route::get('lst', '/lst');
            Route::get('detail/:id', '/detail');
            Route::delete('delete/:id', '/delete');
            Route::post('create', '/create');
            Route::post('update/:id', '/update');
        })->prefix('admin.info.Article');


        Route::group('user_extract',function (){
            Route::group('',function (){
                Route::get('lst','/lst');
            })->prefix('admin.info.Extract');
        });

        Route::group('lawyer',function (){
            Route::post('lst', '/lst');
            Route::post('audit/:id', '/audit');
            Route::post('recommend/:id', '/recommend');
            Route::get('detail/:id', '/detail');
        })->prefix('admin.info.Lawyer');


        Route::group('info',function (){
            Route::post('lst', '/lst');
            Route::post('status/:id', '/status');
            Route::get('getQuestionLst/:id', '/getQuestionLst');
        })->prefix('admin.info.Info');


        Route::group('member',function (){
            Route::get('lst', '/lst');
            Route::delete('delete/:id', '/delete');
            Route::post('update/:id', '/update');
            Route::post('create', '/create');
            Route::get('member_record', '/memberRecord');
        })->prefix('admin.info.Member');


        Route::group('member_setting',function (){
            Route::group('',function (){
                Route::get('lst','/lst');
                Route::post('update/:id','/update');
            })->prefix('admin.info.MemberSetting');
        });


        Route::group('swiper',function (){
            Route::group('',function (){
                Route::get('lst','/getSwiper');
                Route::get('detail/:id','/detailSwiper');
                Route::post('update/:id','/updateSwiper');
                Route::post('create','/createSwiper');
                Route::delete('delete/:id','/deleteSwiper');
            })->prefix('admin.Common');
        });

        //用户
        Route::group('user',function () {
            Route::group('', function () {
                Route::get('lst', '/lst')->name('userLst');
                Route::get('detail/:id', '/detail')->name('userLst');
                Route::post('addIntegral', '/addIntegral');
                Route::post('setProxy', '/setProxy');
                Route::post('setMember', '/setMember');
            })->prefix('admin.user.User');
        });


        Route::post('set_case_type','admin.Common/setCaseType');
        Route::get('get_case_type','admin.Common/getCaseType');

        Route::post('set_main_do','admin.Common/setMainDo');
        Route::get('get_main_do','admin.Common/getMainDo');


        Route::post('set_article_agreement','admin.Common/set_article_agreement');
        Route::get('get_article_agreement','admin.Common/get_article_agreement');

        //管理员
        Route::group('system/admin', function () {
            Route::get('lst', '.Admin/getList')->name('systemAdminLst');
            Route::post('status/:id', '.Admin/switchStatus')->name('systemAdminStatus');
            Route::post('create', '.Admin/create')->name('systemAdminCreate');
            Route::get('create/form', '.Admin/createForm')->name('systemAdminCreateForm');
            Route::post('update/:id', '.Admin/update')->name('systemAdminUpdate');
            Route::get('update/form/:id', '.Admin/updateForm')->name('systemAdminUpdateForm');
            Route::post('password/:id', '.Admin/password')->name('systemAdminPassword');
            Route::get('password/form/:id', '.Admin/passwordForm')->name('systemAdminPasswordForm');
            Route::delete('delete/:id', '.Admin/delete')->name('systemAdminDelete');
            Route::get('edit/form', '.Admin/editForm')->name('systemAdminEditForm');
            Route::post('edit', '.Admin/edit')->name('systemAdminEdit');
            Route::get('edit/password/form', '.Admin/editPasswordForm')->name('systemAdminEditPasswordForm');
            Route::post('edit_password', '.Admin/editPassword')->name('systemAdminEditPassword');
            Route::get('log', '.AdminLog/lst')->name('systemAdminLog');
        })->prefix('admin.system.admin');


        //分类
        Route::group('/category', function () {
            Route::get('create/form/:type', '/createForm')->name('systemCategoryCreateForm');
            Route::get('update/form/:id', '/updateForm')->name('systemCategoryUpdateForm');
            Route::post('update/:id', '/update')->name('systemCategoryUpdate');
            Route::get('lst', '/lst')->name('systemCategoryLst');
            Route::get('detail/:id', '/detail')->name('systemCategoryDetail');
            Route::post('create', '/create')->name('systemCategoryCreate');
            Route::delete('delete/:id', '/delete')->name('systemCategoryDelete');
            Route::post('status/:id', '/switchStatus')->name('systemCategorySwitchStatus');
            Route::get('list/:type', '/getList')->name('systemCategoryList');
            Route::get('/type', '/getCateType')->name('systemCategoryType');
        })->prefix('admin.system.category.Category');

        //配置分类
        Route::group('config/classify', function () {
            Route::get('create/table', '/createTable')->name('configClassifyCreateForm');
            Route::post('create', '/create')->name('configClassifyCreate');
            Route::delete('delete/:id', '/delete')->name('configClassifyDelete');
            Route::post('update/:id', '/update')->name('configClassifyUpdate');
            Route::get('update/table/:id', '/updateTable')->name('configClassifyUpdateForm');
            Route::post('status/:id', '/switchStatus')->name('configClassifySwitchStatus');
            Route::get('lst', '/lst')->name('configClassifyLst');
        })->prefix('admin.system.config.ConfigClassify');

        Route::get('menus', 'admin.system.auth.Menu/menus');
        //配置
        Route::group('config/setting', function () {
            Route::get('create/table', '/createTable')->name('configSettingCreateForm');
            Route::post('create', '/create')->name('configSettingCreate');
            Route::post('update/:id', '/update')->name('configSettingUpdate');
            Route::get('update/table/:id', '/updateTable')->name('configSettingUpdateForm');
            Route::post('status/:id', '/switchStatus')->name('configSettingSwitchStatus');
            Route::get('lst', '/lst')->name('configSettingLst');
            Route::delete('delete/:id', '/delete')->name('configSettingDelete');
            Route::post('upload_file/:field', '/upload')->name('configUpload');
        })->prefix('admin.system.config.Config');

        Route::group('config/others', function () {
            Route::get('lst', 'ConfigOthers/lst')->name('configOthersSettingLst');
            Route::post('update', 'ConfigOthers/update')->name('configOthersSettingUpdate');
            Route::get('group_buying', 'ConfigOthers/getGroupBuying')->name('configOthersGroupBuyingDetail');
            Route::post('group_buying', 'ConfigOthers/setGroupBuying')->name('configOthersGroupBuyingUpdate');
            Route::get('member_option','ConfigOthers/memberOptionDetail')->name('configOthersMemberOptionDetail');
            Route::post('member_option','ConfigOthers/memberOption')->name('configOthersMemberOption');
        })->prefix('admin.system.config.');

        Route::get('config/:key', 'admin.system.config.Config/form')->name('configForm');
        Route::post('config/save/:key', 'admin.system.config.ConfigValue/save')->name('configSave');

        //组合数据
        Route::group('group', function () {
            Route::get('lst', '/lst')->name('groupLst');
            Route::post('create', '/create')->name('groupCreate');
            Route::post('update/:id', '/update')->name('groupUpdate');
            Route::get('create/table', '/createTable')->name('groupCreateForm');
            Route::get('update/table/:id', '/updateTable')->name('groupUpdateForm');
            Route::get('detail/:id', '/get')->name('groupDetail');
            Route::get('data/lst/:groupId', 'Data/lst')->name('groupDataLst');
            Route::get('data/create/table/:groupId', 'Data/createTable')->name('groupDataCreateForm');
            Route::post('data/create/:groupId', 'Data/create')->name('groupDataCreate');
            Route::get('data/update/table/:groupId/:id', 'Data/updateTable')->name('groupDataUpdateForm');
            Route::post('data/update/:groupId/:id', 'Data/update')->name('groupDataUpdate');
            Route::delete('data/delete/:id', 'Data/delete')->name('groupDataDelete');
            Route::post('data/status/:id', 'Data/changeStatus')->name('groupDataChangeStatus');
        })->prefix('admin.system.groupData.Group');

        //权限管理
        Route::group('system/menu', function () {
            Route::get('lst', '/getList')->name('systemMenuGetLst');
            Route::get('create/form', '/createForm')->name('systemMenuCreateForm');
            Route::get('update/form/:id', '/updateForm')->name('systemMenuUpdateForm');
            Route::post('create', '/create')->name('systemMenuCreate');
            Route::post('update/:id', '/update')->name('systemMenuUpdate');
            Route::delete('delete/:id', '/delete')->name('systemMenuDelete');
        })->prefix('admin.system.auth.Menu');


        //身份规则
        Route::group('system/role', function () {
            Route::get('lst', '/getList')->name('systemRoleGetList');
            Route::post('create', '/create')->name('systemRoleCreate');
            Route::get('create/form', '/createForm')->name('systemRoleCreateForm');
            Route::post('update/:id', '/update')->name('systemRoleUpdate');
            Route::get('update/form/:id', '/updateForm')->name('systemRoleUpdateForm');
            Route::post('status/:id', '/switchStatus')->name('systemRoleStatus');
            Route::delete('delete/:id', '/delete')->name('systemRoleDelete');
        })->prefix('admin.system.auth.Role');

        Route::post('agreement_setting','admin.Common/agreementSetting');
        Route::get('agreement','admin.Common/getAgreement');

        Route::post('system_setting','admin.Common/sysSetting');
        Route::get('system_setting','admin.Common/getSysSetting');


        //文件上传
        Route::post('system/upload/:field/[:type]','admin.Common/upload')->name('systemUploadFile');

        //菜单
        Route::get('menus', 'admin.system.auth.Menu/menus');
        //退出登录
        Route::get('logout', 'admin.system.admin.Login/logout');

    })->middleware(AllowOriginMiddleware::class)
        ->middleware(AdminTokenMiddleware::class, true)
        ->middleware(AdminAuthMiddleware::class);


    Route::group(function () {
        //验证码
        Route::get('captcha', 'admin.system.admin.Login/getCaptcha');
        //登录
        Route::post('login', 'admin.system.admin.Login/login');
        Route::get('login_config', 'admin.Common/loginConfig');
    })->middleware(AllowOriginMiddleware::class);
});
